package net.esj.basic.utils.pad;

import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import net.esj.basic.core.view.tools.ActionContext;
import net.esj.basic.utils.StringUtils;

public class PadSessionListener implements HttpSessionListener {

	private static final String PAD_REQUEST_HEAD = "PAD";
	
	private static final String PAD_SESSION_ID ="psession";
	
	private Map<String, HttpSession> cached = new ConcurrentHashMap<String, HttpSession>();
	
	@Override
	public void sessionCreated(HttpSessionEvent event) {
		String pad = ((HttpServletRequest)ActionContext.getRequest()).getHeader(PAD_REQUEST_HEAD);
//		if(!StringUtils.hasText(pad))
//			return;
		String psession = ((HttpServletRequest)ActionContext.getRequest()).getHeader(PAD_SESSION_ID);
		if(StringUtils.hasText(psession)){
		}
		Enumeration<String> it = ((HttpServletRequest)ActionContext.getRequest()).getHeaderNames();
		while(it.hasMoreElements()){
			String str = it.nextElement();
			System.out.println(str+"-------------"+ ((HttpServletRequest)ActionContext.getRequest()).getHeader(str));
		}
		System.out.println(pad);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent event) {

	}
	
	private void copyAttribute(HttpSession oldOne,HttpSession newOne){
		
	}

}
